angular.module('wf-utils')
#本方法用于弹出提示消息或警告窗口。
#       提示=toast，警告=alert
#       info及error等后缀用于适配弹出框样式
.service('wfAlert',()->
    time=2500
    toast=(type,msg)->
        if($('#alert-container .head-toast').length>0)
#            console.log('限制重复alert')
            return
        else
            template = "<div class='head-toast'><header class='toast-"+type+"'><span>"+msg+"</span></header></div>"
            $('#alert-container').append(template)
            console.log($('#alert-container'))
#            $('#alert-container .head-toast').eq(0).css('animation','head-toast 3.1s ease-in-out')
            setTimeout(()->
                $('#alert-container').empty()
            ,time)
    alert=(type,msg)->
        ''
    toastInfo:(msg)->
        toast('info',msg)
        console.log('toastInfo:',msg)
    toastError:(msg)->
        toast('error',msg)
        console.log('toastError:',msg)
    alertInfo:(msg)->
        console.log('alertInfo:',msg)
    alertError:(msg)->
        console.log('alertError:',msg)
)

.constant 'inWeixin', /micromessenger/.test(navigator.userAgent.toLowerCase())
.service 'isMobile',($localStorage)->
    u = navigator.userAgent
    $localStorage['isMobile']=!!u.match(/Mobile.*/)
